home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / PCBREG.SLT < prev    next >
Text File  |  1992-03-20  |  10KB  |  319 lines

  1. //-----------------------------------------------------------
  2. // PCBREG.SL? Automatic registration to a new MBBS.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs before you use it. Then recompile with CS PCBREG. 
  6. //-----------------------------------------------------------
  7.  
  8. // If you have suggestions for improving this script, please suggest
  9. // improvements to me via old-fashioned snail-mail to:
  10.  
  11. // Author:  Inge Vabekk
  12. //          Hamangskogen 108
  13. //          N-1300 SANDVIKA
  14. //          NORWAY
  15. //          tel. (472) 546 396
  16.  
  17. str thisBBStype[]="PCB"      // Works only for PCBoard.
  18.    ,line   [80]              // Line for string storage.
  19.    ,help   [20]              // Line for string storage.
  20.                              // For the Global storage:
  21.    ,global   []="GLOBAL"     // Global script.
  22.    ,bbstype  []="BTYPE"      // BBS type.
  23.    ,hisprot  []="HPROT"      // BBS's protocol characters.
  24.    ,passw    []="PASSW"      // Current password.
  25.    ,addr     []="ADDR"       // Address
  26.    ,mail     []="MAIL"       // Mail address
  27.    ,state    []="STATE"      // Country
  28.    ,htel     []="HTEL"       // Home phone
  29.    ,wtel     []="WTEL"       // Work phone
  30.    ,cpu      []="CPU"        // Computer model
  31.    ;     
  32.  
  33. int tol = 300                            // No activity for ½ minute
  34.    ,stat, tmark                          // gives automatic exit.
  35.    ,i, norsk = 0
  36.    ;
  37.  
  38. //-----------------------------------------------------------
  39. // Script starts here.
  40. //-----------------------------------------------------------
  41.  
  42. main()
  43. {
  44. int error;
  45.  
  46.   entry();                               // Updates colors & status bar. 
  47.  
  48.   call (global,"R",bbstype,line);        // Get BBS type. Should be MBBS.
  49.  
  50.   if (line != thisBBStype)  
  51.   { wrongBBS();
  52.     return (-1);
  53.   }
  54.  
  55. // Only if online.
  56.  
  57.   if (!carrier())  
  58.   { alarm(1);
  59.     status_wind ("T²: THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  60.     return (0);
  61.   }
  62.  
  63. // Start tracking incoming text. For ease of reading and programming,
  64. // and to improve the speed of the program on slow computers, this is
  65. // split into different sections.
  66. //-----------------------------------------------------------
  67.  
  68.   cputs ("C^M");                         // Continue registration.
  69.   if (waitfor ("register with us",10))
  70.     cputs ("Y^M");
  71.   else
  72.   { cputs ("n^M");
  73.     return (-1);
  74.   }
  75.   error = 0;
  76.   SECTION1();                            // These set error = -1
  77.                                          // by failure.
  78.   release();                             // Free timer and tracks.
  79.   if (error < 0) goto fail;
  80.  
  81.   SECTION2();
  82.   release();
  83.   if (!error)
  84.   { if (waitfor ("Command?",180))        // Command?
  85.     { cputs ("X^M");                     // Set Xpert mode.
  86.       waitfor ("Command?",10);           // Wait for next command.
  87.     }
  88.     goto done;                           // Return to caller.
  89.   }
  90. fail:
  91.    status_wind ("T²: Registration failed!",20);
  92.    error = -1;            
  93.  
  94. done:
  95.    return (error);
  96. }
  97.  
  98. //-----------------------------------------------------------
  99. // Start registration.
  100. //-----------------------------------------------------------
  101.  
  102. SECTION1()
  103. {
  104. int c, error;
  105.                    // Variables ysed for text tracking:
  106. int pw             // Password
  107.    ,mo1, mo2       // More?
  108.    ,mo3, mo4       // (answer NO to these four prompts)
  109.    ,pro
  110.    ,ma             // Mail address
  111.    ,ci             // City calling from
  112.    ,cs             // City and state calling from
  113.    ;
  114.   error = -1;
  115.  
  116.   mo1= track ("(NS)non-stop?",0);        // More?
  117.   mo2= track ("(H)elp, More?",0);
  118.   mo3= track ("each message?",0);
  119.   mo4= track ("Message Base ",0);        // Scan message base?
  120.   pro= track ("Protocol Desi",0);        // Default protocol desired
  121.  
  122.   pw = track ("password",1);             // Password
  123.   ma = track ("dress?",0);               // Mail address
  124.   cs = track ("State calling",0);        // City and state calling from? 
  125.   ci = track ("City calling", 0);        // City calling from?
  126.   
  127.   tmark = timer_start (tol);             // wait up to 1 minute for 
  128.                                          // each response.
  129.   while ((stat=trig()) > 0)              // answer any questions.
  130.   { if (stat == pw)                      // Password
  131.       output (passw);
  132.    
  133.     else if (stat==mo1 || stat==mo2      // More?
  134.          ||  stat==mo3 || stat==mo4)
  135.       cputs ("n^M");                     // Not now please.
  136.  
  137.     else if (stat == pro)                // Default protocol
  138.       output (hisprot);
  139.  
  140.     else if (stat == ma)                 // Mail address
  141.       output (addr);
  142.  
  143.     if ((stat==ci) || (stat==cs))        // City (and state)?
  144.     { call (global,"R",mail,line);
  145.       for (i=0; i<strlen (line); ++i)
  146.       { c=subchr (line,i);               // Extract postnr. from string.
  147.         if (!isdigit(c) && c!=' ') break;
  148.       }
  149.       subchrs (line,i,20-i,help);
  150.       cputs (help);                      // give city.
  151.       if (stat == cs)
  152.       { cputs (" ");                     // Give country.
  153.         output (state);
  154.       }
  155.       else
  156.         cputs ("^M");                    // CR.
  157.       error = 0;
  158.       break;                             // This section done.         
  159.     }
  160.   }
  161.  
  162.   return (error);                        // Good or bad.
  163. }
  164.  
  165. //-----------------------------------------------------------
  166. // Section 2 of registration.
  167. //-----------------------------------------------------------
  168.  
  169. SECTION2()
  170. {
  171. int error;
  172.                    // Variables used for text tracking:
  173. int pw             // Please wait...
  174.    ,mo1, mo2       // More?
  175.    ,en             // Press (Enter) to continue: 
  176.    ,hp             // Home phone
  177.    ,wp             // Work phone
  178.    ,bc1, bc2       // Brand of CPU
  179.    ,cls            // Clear screen?
  180.    ,pro            // Protocol?
  181.    ;
  182.   error = -1;                            // Start new trackings.
  183.  
  184.   wp = track ("data phone #",0);         // Business or data phone
  185.   hp = track ("oice phone #",0);         // Home or voice phone
  186.   en = track (" to continue",0);         // ENTER to continue.
  187.   pw = track ("Please Wait ",0);         // Please wait.
  188.   
  189.   mo1 = track ("(NS)non-stop?",0);       // More?
  190.   mo2 = track ("Message Base ",0);       // Scan message base?
  191.   bc1 = track ("CPU ",0);                // Brand of CPU in use.
  192.   bc2 = track ("Computer ",1);
  193.   cls = track ("essage? (",0);           // Clear screen betw. messages
  194.   pro = track ("change? (",0);           // Protocol?
  195.  
  196.   tmark = timer_start (tol);             // wait up to 1 minute for 
  197.                                          // each response.
  198.   while ((stat=trig()) > 0)              // answer any questions.
  199.   { if (stat==mo1 || stat==mo2           // More?
  200.       || stat==cls)                      // Clear screen?
  201.       cputs ("N^M");                     // Not now please.
  202.  
  203.     else if (stat==en || stat==pro)     // ENTER to continue
  204.       cputs ("^M");
  205.  
  206.     else if (stat == hp)                   // Home phone number
  207.       output (htel);
  208.  
  209.     else if (stat == wp)                   // Work phone number
  210.       output (wtel);
  211.  
  212.     else if (stat==bc1 || stat==bc2)     // CPU type?
  213.       output (cpu);
  214.  
  215.     else if (stat == pw)                   // Please wait...
  216.     { error = 0;
  217.       break;
  218.     }
  219.   }
  220.   return (error);
  221. }
  222.  
  223. //-----------------------------------------------------------
  224. // Wrong BBS type.
  225. //-----------------------------------------------------------
  226.  
  227. wrongBBS()
  228. {
  229. str help[48];
  230.  
  231.     failtone();                          // Alarm.    
  232.     help = "This script is for ";        // Catenate strings.
  233.     strcat (help,thisBBStype);
  234.     strcat (help," only!");
  235.     status_wind (help,20);               // Display message for 2 sec.
  236. }
  237.  
  238. //-----------------------------------------------------------
  239. // Play fail tone.
  240. //-----------------------------------------------------------
  241.  
  242. failtone()
  243. {
  244.   int n;
  245.   for (n=140; n > 10; n = 100*n/120) 
  246.   { tone(n*10,12);                       // Fail tone!!
  247.     terminal();